﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:SL8.SL.Controls"
    xmlns:localconverters="clr-namespace:SL8.SL.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

    <Style TargetType="local:TaskCalendar">
        <Setter Property="WeekDayTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid Background="AliceBlue">
                        <TextBlock Text="{Binding}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="DayItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid x:Name="Root" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <Grid.Resources>
                            <localconverters:BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter"/>
                        </Grid.Resources>
                        <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Command="{Binding SelectedCommand}">
                            <Button.Template>
                                <ControlTemplate TargetType="Button">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition/>
                                            <RowDefinition Height="4"/>
                                        </Grid.RowDefinitions>
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualStateGroup.Transitions>
                                                    <VisualTransition GeneratedDuration="0:0:0.5"/>
                                                </VisualStateGroup.Transitions>
                                                <VisualState x:Name="Normal"/>
                                                <VisualState x:Name="MouseOver">
                                                    <Storyboard>
                                                        <DoubleAnimation Duration="0" To="0.8" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="rectMouseOver" d:IsOptimized="True"/>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Pressed"/>
                                                <VisualState x:Name="Disabled"/>
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <!--背景-->
                                        <Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="#01FFFFFF" Opacity="0.001"/>

                                        <!--工作日-->
                                        <Rectangle Visibility="{Binding IsWorkDay, ConverterParameter=1, Converter={StaticResource booleanToVisibilityConverter}}"   HorizontalAlignment="Stretch" VerticalAlignment="Stretch"   Fill="#FFEEEEEE" Grid.RowSpan="2"/>

                                        <!--选中-->
                                        <Rectangle Visibility="{Binding IsChecked, Converter={StaticResource booleanToVisibilityConverter}}"   HorizontalAlignment="Stretch" VerticalAlignment="Stretch"   Fill="Aquamarine"/>

                                        <!--当日-->
                                        <Rectangle Visibility="{Binding IsCurrentDay, Converter={StaticResource booleanToVisibilityConverter}}" StrokeThickness="1"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Stroke="Red" Fill="{x:Null}"/>

                                        <!--当前月份日-->
                                        <TextBlock  FontSize="12" HorizontalAlignment="Center" Foreground="#FFAAAAAA" Visibility="{Binding IsCurrentMonth, ConverterParameter=1, Converter={StaticResource booleanToVisibilityConverter}}" VerticalAlignment="Center" Text="{Binding Date.Day}"/>

                                        <!--不是当前月份日-->
                                        <TextBlock HorizontalAlignment="Center"  FontSize="14" Visibility="{Binding IsCurrentMonth, Converter={StaticResource booleanToVisibilityConverter}}" VerticalAlignment="Center" Text="{Binding Date.Day}"/>

                                        <!--历史线-->
                                        <Rectangle Grid.Row="1" Visibility="{Binding IsPass, Converter={StaticResource booleanToVisibilityConverter}}"   HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="2" Fill="Green"/>
                                        <Rectangle x:Name="rectMouseOver" Stroke="Black" StrokeDashArray="2 2" Opacity="0"/>
                                    </Grid>
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="MonthTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid x:Name="Root" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <Grid.Resources>
                            <localconverters:BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter"/>
                        </Grid.Resources>
                        <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Command="{Binding SelectedCommand}">
                            <Button.Template>
                                <ControlTemplate TargetType="Button">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition/>
                                            <RowDefinition Height="4"/>
                                        </Grid.RowDefinitions>
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualStateGroup.Transitions>
                                                    <VisualTransition GeneratedDuration="0:0:0.5"/>
                                                </VisualStateGroup.Transitions>
                                                <VisualState x:Name="Normal"/>
                                                <VisualState x:Name="MouseOver">
                                                    <Storyboard>
                                                        <DoubleAnimation Duration="0" To="0.8" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="rectMouseOver" d:IsOptimized="True"/>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Pressed"/>
                                                <VisualState x:Name="Disabled"/>
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <!--背景-->
                                        <Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="#01FFFFFF" Opacity="0.001"/>

                                        <!--月份-->
                                        <TextBlock  FontSize="14" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Date.Month}"/>

                                        <!--当月-->
                                        <Rectangle Visibility="{Binding IsCurrentMonth, Converter={StaticResource booleanToVisibilityConverter}}" StrokeThickness="1"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Stroke="Red" Fill="{x:Null}"/>

                                        <!--历史线-->
                                        <Rectangle Grid.Row="1" Visibility="{Binding IsPass, Converter={StaticResource booleanToVisibilityConverter}}"   HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="2" Fill="Green"/>
                                        <Rectangle x:Name="rectMouseOver" Stroke="Black" StrokeDashArray="2 2" Opacity="0"/>
                                    </Grid>
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:TaskCalendar">
                    <Grid x:Name="Root">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="28"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Button Content="Prev" x:Name="PrevButton" Grid.Column="0">
                                <Button.Template>
                                    <ControlTemplate TargetType="Button">
                                        <Grid Width="28" Height="16">
                                            <VisualStateManager.VisualStateGroups>
                                                <VisualStateGroup x:Name="CommonStates">
                                                    <VisualState x:Name="Normal"/>
                                                    <VisualState x:Name="MouseOver">
                                                        <Storyboard>
                                                            <DoubleAnimation Duration="0" To="0.75" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="pathMouseOver" d:IsOptimized="True"/>
                                                        </Storyboard>
                                                    </VisualState>
                                                    <VisualState x:Name="Pressed"/>
                                                    <VisualState x:Name="Disabled"/>
                                                </VisualStateGroup>
                                            </VisualStateManager.VisualStateGroups>
                                            <Rectangle Fill="#01000000" Opacity="0.01"/>

                                            <Path x:Name="pathMouseOver" Data="M7.8665786,7.4166665 L9.9169998,3.1663334 L9.9000359,10.916607 z" Stretch="Fill" UseLayoutRounding="False" Fill="Black" Width="5" HorizontalAlignment="Center" VerticalAlignment="Center" Height="9" StrokeThickness="0"/>

                                        </Grid>
                                    </ControlTemplate>
                                </Button.Template>
                            </Button>
                            <Button Content="Next" x:Name="NextButton" Grid.Column="2">
                                <Button.Template>
                                    <ControlTemplate TargetType="Button">
                                        <Grid Width="28" Height="16">
                                            <VisualStateManager.VisualStateGroups>
                                                <VisualStateGroup x:Name="CommonStates">
                                                    <VisualState x:Name="Normal"/>
                                                    <VisualState x:Name="MouseOver">
                                                        <Storyboard>
                                                            <DoubleAnimation Duration="0" To="0.75" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="pathMouseOver" d:IsOptimized="True"/>
                                                        </Storyboard>
                                                    </VisualState>
                                                    <VisualState x:Name="Pressed"/>
                                                    <VisualState x:Name="Disabled"/>
                                                </VisualStateGroup>
                                            </VisualStateManager.VisualStateGroups>
                                            <Rectangle Fill="#01000000" Opacity="0.01"/>

                                            <Path x:Name="pathMouseOver" Data="M7.3656931,6.9737935 L6.1097212,3.0556533 L6.1154351,11.027325 z" Stretch="Fill" UseLayoutRounding="False" Fill="Black" HorizontalAlignment="Center" VerticalAlignment="Center" Height="9" Width="5"/>

                                        </Grid>
                                    </ControlTemplate>
                                </Button.Template>
                            </Button>

                            <Button VerticalAlignment="Center" Visibility="Collapsed" HorizontalAlignment="Center" x:Name="DayView_HeaderButton" Grid.Column="1" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                <Button.Template>
                                    <ControlTemplate TargetType="Button">
                                        <Grid>
                                            <VisualStateManager.VisualStateGroups>
                                                <VisualStateGroup x:Name="CommonStates">
                                                    <VisualState x:Name="Normal"/>
                                                    <VisualState x:Name="MouseOver">
                                                        <Storyboard>
                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="pathMouseOver">
                                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                                    <DiscreteObjectKeyFrame.Value>
                                                                        <Visibility>Visible</Visibility>
                                                                    </DiscreteObjectKeyFrame.Value>
                                                                </DiscreteObjectKeyFrame>
                                                            </ObjectAnimationUsingKeyFrames>
                                                        </Storyboard>
                                                    </VisualState>
                                                    <VisualState x:Name="Pressed"/>
                                                    <VisualState x:Name="Disabled"/>
                                                </VisualStateGroup>
                                            </VisualStateManager.VisualStateGroups>
                                            <Rectangle x:Name="pathMouseOver" Fill="Black" Opacity="0.25" RadiusY="6" RadiusX="6" StrokeThickness="0" Margin="2" Visibility="Collapsed"/>
                                            <TextBlock Text="{Binding VisualStartDate, StringFormat=yyyy年MM月}" FontSize="14" Margin="8,4" FontWeight="Bold" />
                                        </Grid>
                                    </ControlTemplate>
                                </Button.Template>
                            </Button>
                            <Button VerticalAlignment="Center"  Visibility="Collapsed" HorizontalAlignment="Center" x:Name="MonthView_HeaderButton" Grid.Column="1" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                <Button.Template>
                                    <ControlTemplate>
                                        <Grid>
                                            <VisualStateManager.VisualStateGroups>
                                                <VisualStateGroup x:Name="CommonStates">
                                                    <VisualState x:Name="Normal"/>
                                                    <VisualState x:Name="MouseOver">
                                                        <Storyboard>
                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="pathMouseOver">
                                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                                    <DiscreteObjectKeyFrame.Value>
                                                                        <Visibility>Visible</Visibility>
                                                                    </DiscreteObjectKeyFrame.Value>
                                                                </DiscreteObjectKeyFrame>
                                                            </ObjectAnimationUsingKeyFrames>
                                                        </Storyboard>
                                                    </VisualState>
                                                    <VisualState x:Name="Pressed"/>
                                                    <VisualState x:Name="Disabled"/>
                                                </VisualStateGroup>
                                            </VisualStateManager.VisualStateGroups>
                                            <Rectangle x:Name="pathMouseOver" Fill="Black" Opacity="0.25" RadiusY="6" RadiusX="6" StrokeThickness="0" Margin="2" Visibility="Collapsed"/>
                                            <TextBlock Text="{Binding VisualStartDate, StringFormat=yyyy年}"  Margin="8,4" FontSize="14" FontWeight="Bold"/>
                                        </Grid>
                                    </ControlTemplate>
                                </Button.Template>
                            </Button>
                        </Grid>
                        <Grid x:Name="MonthView" Grid.Row="1" Visibility="Collapsed">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>
                        </Grid>
                        <Grid Grid.Row="1"  x:Name="DayView">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="28"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid x:Name="WeekDayView" Grid.Row="0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                            </Grid>
                            <Grid x:Name="DayItemsView" Grid.Row="1">
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                            </Grid>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
